//
//  CostTableViewCell.m
//  WWXELuShang
//
//  Created by 王涛 on 15/12/21.
//  Copyright © 2015年 lanou. All rights reserved.
//

#import "CostTableViewCell.h"
#import "CostModel.h"
@implementation CostTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        CGFloat height = kHeight / 9;
        CGFloat imagewidth = kHeight / 13;
        self.dateLabel = [[UILabel alloc] initWithFrame:(CGRectMake(0, height / 3, kWidth / 2 - imagewidth / 2, height / 3))];
        self.dateLabel.font = [UIFont systemFontOfSize:15];
        self.dateLabel.textAlignment = NSTextAlignmentCenter;
        self.dateLabel.textColor = [UIColor darkGrayColor];
        [self addSubview:self.dateLabel];
        
        self.picView = [[UIImageView alloc] initWithFrame:(CGRectMake(kWidth / 2 - imagewidth / 2, (height - imagewidth) / 2, imagewidth, imagewidth))];
        self.picView.layer.borderColor = [[UIColor redColor] CGColor];
        self.picView.layer.borderWidth = 2;
        self.picView.layer.masksToBounds = YES;
        self.picView.layer.cornerRadius = imagewidth / 2;
        [self addSubview:self.picView];
        
        UILabel *label = [[UILabel alloc] initWithFrame:(CGRectMake(kWidth / 2 - 2, 0, 4, (height - imagewidth) / 2))];
        label.backgroundColor = [UIColor lightGrayColor];
        [self addSubview:label];
        UILabel *label1 = [[UILabel alloc] initWithFrame:(CGRectMake(kWidth / 2 - 2, (height + imagewidth) / 2, 4, (height - imagewidth) / 2))];
        label1.backgroundColor = [UIColor lightGrayColor];
        [self addSubview:label1];
        
        self.nameLabel = [[UILabel alloc] initWithFrame:(CGRectMake(kWidth / 2 + imagewidth / 2 + kWidth / 37.5, height / 3, kWidth / 2 - imagewidth / 2 - kWidth / 37.5, height / 3))];
        self.nameLabel.textColor = [UIColor darkGrayColor];
        self.nameLabel.font = [UIFont systemFontOfSize:15];
        [self addSubview:self.nameLabel];
        
        
    }
    return self;
}
- (void)setCostModel:(CostModel *)costModel {
    if (_costModel != costModel) {
        _costModel = costModel;
        self.dateLabel.text = costModel.date;
        self.dateLabel.text = [costModel.date substringToIndex:16];
        self.picView.image = [UIImage imageWithData:costModel.imagedata];
        NSString *string = [[@"  " stringByAppendingString:costModel.money] stringByAppendingString:@".00"];
        self.nameLabel.text = [costModel.name stringByAppendingString:string];
    }
}





- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
